//
//  LSUserGuideViewController.m
//  LookScore
//
//  Created by wr on 2017/12/4.
//  Copyright © 2017年 ChongQingXunTiCompany. All rights reserved.
//
#define pageIndex 3

#import "LSUserGuideViewController.h"
#import "LSBaseTabBarController.h"
#import "XYSideViewController.h"
#import "UIViewController+XYSideCategory.h"
#import "LSMineVController.h"
#import "LSGuideView.h"
@interface LSUserGuideViewController ()<UIScrollViewDelegate,LSGuideViewDelegate>


@property (nonatomic, strong) UIPageControl *pageControl;
@property (nonatomic, strong) LSMineVController *leftVC;
@property (assign,nonatomic) BOOL isFirstLaunch;
@property (strong,nonatomic) LSGuideView *guideView;

@end

@implementation LSUserGuideViewController
//{
//    BOOL _config;
//}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    if (![[NSUserDefaults standardUserDefaults] boolForKey:@"isFirstLaunch"]) {
        _isFirstLaunch = YES;
        [[NSUserDefaults standardUserDefaults] setBool:_isFirstLaunch forKey:@"isFirstLaunch"];
        [[NSUserDefaults standardUserDefaults] synchronize];
        _guideView = [[LSGuideView alloc]initWithFrame:[UIScreen mainScreen].bounds];
        _guideView.delegate = self;
        //        [self loadConfig];
        [self.view addSubview:_guideView];
    }
}



- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    MyLog(@"fhdsuifhius");
//    [self createChildController];
//    [self loadConfig];
    
}

#pragma mark 创建子视图
-(void)createChildController{
    
//   //创建scrollView
//    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
//    scrollView.showsHorizontalScrollIndicator = NO;
//    scrollView.showsVerticalScrollIndicator = NO;
//    scrollView.pagingEnabled = YES;
//    scrollView.bounces = NO;
//    scrollView.delegate = self;
//    [self.view addSubview:scrollView];
//    scrollView.contentSize = CGSizeMake(pageIndex*LSScreenWidth,LSScreenHeight);
//
//    //添加滚动图片
//    for (int i = 0; i<pageIndex; i++) {
//
//        UIImageView *imageview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, LSScreenWidth*i,LSScreenHeight)];
//        [imageview setImage:[UIImage imageNamed:[NSString stringWithFormat:@"start%d",i]]];
//        [scrollView addSubview:imageview];
//
//        if(i==(pageIndex-1)){
//            [imageview addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(firstPressed)]];
//            imageview.userInteractionEnabled = YES;
//        }
//    }
//
//    //创建pageControl
//    UIPageControl *pageControl = [[UIPageControl alloc]init];
//    pageControl.currentPageIndicatorTintColor =Color(255, 255, 255);
//    pageControl.pageIndicatorTintColor = [UIColor whiteColor];
//    pageControl.numberOfPages = pageIndex;
//    [pageControl sizeToFit];
//    CGRect frame = pageControl.frame;
//    pageControl.frame = CGRectMake(LSScreenWidth/2-frame.size.width/2, LSScreenHeight-50,frame.size.width, frame.size.height);
//    [self.view addSubview:pageControl];
//    self.pageControl =pageControl;
   
}

#pragma mark 🔥引导进入APP
- (void)onPassButtonPressed{
    //左侧菜单
    self.leftVC = [[LSMineVController alloc] init];
    //创建滑动菜单
    LSBaseTabBarController *rootVC = [[LSBaseTabBarController alloc] init];
//    rootVC.isOk = _config;
    XYSideViewController *rootViewController = [[XYSideViewController alloc] initWithSideVC:self.leftVC currentVC:rootVC];
    [self.view.window addSubview:rootViewController.view];
    self.view.window.rootViewController = rootViewController;
}
//- (void)firstPressed{
//
////    LSBaseTabBarController *tabBarVC= [[LSBaseTabBarController alloc] init];
////
////    self.view.window.rootViewController = tabBarVC;  //点击button跳转到根视图
//
//
//    //左侧菜单
//    self.leftVC = [[LSMineVController alloc] init];
//    //创建滑动菜单
//    LSBaseTabBarController *rootVC = [[LSBaseTabBarController alloc] init];
//    XYSideViewController *rootViewController = [[XYSideViewController alloc] initWithSideVC:self.leftVC currentVC:rootVC];
//    [self.view.window addSubview:rootViewController.view];
//    self.view.window.rootViewController = rootViewController;
//}

//- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
//    int currentPage =  scrollView.contentOffset.x/LSScreenWidth+0.5;
//    self.pageControl.currentPage=currentPage;
//}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
